package com.roc.template.mysql.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.roc.template.base.PageBean;
import com.roc.template.mysql.entity.Order;
import com.roc.template.mysql.mapper.OrderMapper;
import com.roc.template.mysql.service.OrderService;
import com.roc.template.mysql.vo.OrderVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName OrderServiceImpl
 * @Description: TODO
 * @Author Administrator
 * @Date 2020/7/20 15 39
 * @Version V1.0
 **/
@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;


    @Override
    public PageBean<Order> pageQuery(OrderVo orderVo) {
        PageHelper.startPage(orderVo.getPageNum(), orderVo.getPageSize());
        List<Order> orders = orderMapper.pageQuery(orderVo);
        PageInfo<Order> pageInfo = new PageInfo<>(orders);
        return new PageBean<>(pageInfo);
    }

    @Override
    public void insert(Order order) {
         orderMapper.insert(order);
    }

    @Override
    public void delete(String id) {
        orderMapper.delete(id);
    }

    @Override
    public void update(Order order) {
        orderMapper.update(order);
    }
}
